﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MCP.Data.BL
{
	public class AuthenticationResult
	{
		public AuthenticationResult(AuthenticationResultType type)
		{
			this.ResultType = type;
			if (type == AuthenticationResultType.NoUserEntered || type == AuthenticationResultType.UnknownUser)
			{
				this.NotificationPlace = ErrorNotificationPlace.Login;
			}
			else if (type == AuthenticationResultType.NoPasswordEntered || type == AuthenticationResultType.WrongPassword)
			{
				this.NotificationPlace = ErrorNotificationPlace.Password;
			}
			else
			{
				this.NotificationPlace = null;
			}
		}

		public AuthenticationResultType ResultType { get; private set; }

		public ErrorNotificationPlace? NotificationPlace { get; private set; }

		public string Message
		{
			get
			{
				string message = string.Empty;
				switch (ResultType)
				{
						case AuthenticationResultType.Authorized:
						{
							message = string.Empty;
							break;
						}
						case AuthenticationResultType.WrongPassword:
						{
							message = "Incorrect password";
							break;
						}
						case AuthenticationResultType.UnknownUser:
						{
							message = "No user found.";
							break;
						}
						case AuthenticationResultType.NoUserEntered:
						{
							message = "Empty login.";
							break;
						}
						case AuthenticationResultType.NoPasswordEntered:
						{
							message = "Empty password.";
							break;
						}
				}

				return message;
			}
		}
	}

	public enum ErrorNotificationPlace : int
	{
		Login,
		Password,
		General
	}
}
